///////////////////////////////////////////////////////////////////////////////
//
// Licensed under the MIT License
//
// Copyright (c) 2010 Chris Colinsky
// All Rights Reserved
//
// version	0.5
// http://code.google.com/p/sugarcookie/
// http://code.google.com/p/sugarcookie/wiki/License
//
////////////////////////////////////////////////////////////////////////////////

package sugarcookie.commands {
	import sugarcookie.commands.ICommand;
	import sugarcookie.error.ApplicationError;
	import sugarcookie.framework.IViewStack;
	import sugarcookie.framework.vo.NavData;
	
	/**
	 * 
	 */
	public class NavigateCommand implements ICommand {
		private var _receiver:IViewStack;
		private var _navdata:NavData;
		
		public function NavigateCommand(receiver:IViewStack,navdata:NavData=null) {
			_receiver = receiver;
			_navdata = navdata;
		}
		
		public function set navdata(value:NavData):void {
			_navdata = value;
		}
		
		public function execute():void {
			if (_navdata==null) throw new ApplicationError("The NavData object has not been assigned.");
			else _receiver.navigate(_navdata);
		}
		
		public function clone():ICommand {
			return new NavigateCommand(_receiver,_navdata);
		}
	}
}